package gui.commands.stateDiagramCommands;

import data.DataVector;
import data.classDiagram.ClassEntity;
import data.classDiagram.Trigger;
import data.stateDiagram.State;
import data.stateDiagram.Transition;
import gui.commands.ICommand;

/**
 * User: Szymon Kudzia
 * Date: 12.05.13
 * Time: 14:37
 */
public class DeleteTransitionCommand implements ICommand {
	protected Transition transition;
	protected ClassEntity entity;

	public DeleteTransitionCommand(ClassEntity entity, Transition transition) {
		this.entity = entity;
		this.transition = transition;
	}

	@Override
	public void execute() {
		entity.getTriggers().remove(transition.getTrigger());
		entity.getStateDiagram().getTransitions().remove(transition);

		DataVector.getInstance().refresh();
	}

	@Override
	public void undo() {
		entity.getTriggers().add(transition.getTrigger());
		entity.getStateDiagram().addTransition(transition);

		DataVector.getInstance().refresh();
	}

	@Override
	public void redo() {
		execute();
	}
}
